<?php
/**
 * @version $Id: default.php 24 2009-03-29 13:19:58Z der.el.kuku $
 * @package    WikiInclude
 * @subpackage
 * @author     EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author     Nikolai Plath {@link http://www.easy-joomla.org}
 * @author     Created on 26-Mar-2009
 */

//--No direct access
defined( '_JEXEC' ) or die( '=;)' );

#$ttt = $this->getWebPage('http://nik-it.de');
#print_r( $ttt);

$linkUpdate = 'index.php?option=com_wikiinclude&controller=wikiinclude&task=update&tmpl=component';//&controller='.strtolower(EASY_APP_4).'

?>
<script type="text/javascript">
	function wikiUpdate(i, id)
	{
		$('link'+i).innerHTML = 'Processing...';
		$('repicon'+i).setProperty('class', 'img-16 img-small icon-16-report_do');
		new Ajax('<?php echo $linkUpdate; ?>&id='+id, {
			update:'result'+i,
			onComplete: function(){ $('repicon'+i).setProperty('class', 'img-16 img-small icon-16-report_1');
				 $('link'+i).innerHTML = '';
			}
		}).request();
		return false;
	}//function
</script>

<form action="index.php" method="post" name="adminForm">
<div id="editcell">
	<table class="adminlist">
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'ID' ); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
			</th>
			<th>
				<?php echo JText::_( 'Title' ); ?>
			</th>
			<th>
				<?php echo JText::_( 'Last updated' ); ?>
			</th>
			<th>
				<?php echo JText::_( 'Wiki rev' ); ?>
			</th>
			<th colspan="2">
				<?php echo JText::_( 'Action' ); ?>
			</th>
		</tr>			
	</thead>
	<tbody>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)
	{
		$row = &$this->items[$i];
		$checked = JHTML::_('grid.id',   $i, $row->id );
		$link = JRoute::_( 'index.php?option=com_wikiinclude&controller=wikiinclude&task=edit&cid[]='. $row->id );
		$previewLink = JRoute::_( 'index.php?option=com_wikiinclude&controller=wikiinclude&task=preview&cid='. $row->id );
		
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $row->id; ?>
			</td>
			<td>
				<?php echo $checked; ?>
			</td>
			<td>
				<a href="<?php echo $link; ?>"><?php echo $row->title; ?></a>
			</td>
			<td><?php echo $row->last_updated; ?></td>
			<td><?php echo $row->wikirev; ?></td>
			<td>
				<div class="img-16 img-small icon-16-report_<?php echo $row->stat_reported; ?> hasTip" id="repicon<?php echo $i; ?>" title=""></div>
				<a id="link<?php echo $i; ?>" style="cursor: pointer; color: #0b55c4;" onclick="wikiUpdate(<?php echo $i.', '.$row->id; ?>);">Update</a>
				<div id="result<?php echo $i; ?>"></div>
			</td>
			<td>
				<a href="<?php echo $previewLink; ?>"><?php echo JText::_('Preview'); ?></a> 
			</td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</tbody>
	 <tfoot>
    <tr>
      <td colspan="7">
      	<?php echo $this->pagination->getListFooter(); ?>
      </td>
    </tr>
  </tfoot>
	</table>
</div>

<input type="hidden" name="option" value="com_wikiinclude" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="wikiinclude" />
</form>
